package java_test.reflection;

import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public class OtherTest {
    public static void main(String[] args) {
        Class clazz = Person1.class;
        Constructor[] constructors = clazz.getConstructors();
        for (Constructor c : constructors)   {
            System.out.println(c);
        }
        System.out.println();
        Constructor[] declaredConstructors = clazz.getDeclaredConstructors();
        for (Constructor c : declaredConstructors) {
            System.out.println(c);
        }
        System.out.println();

        Class superclass = clazz.getSuperclass();
        System.out.println(superclass);

        System.out.println();

        Type genericSuperclass = clazz.getGenericSuperclass();
        System.out.println(genericSuperclass);

        System.out.println();
        ParameterizedType parameterizedType = (ParameterizedType) genericSuperclass;
        Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
        for (Type actualTypeArgument : actualTypeArguments) {
            System.out.println(actualTypeArgument.getTypeName());
        }
        System.out.println();
        Class[] interfaces = clazz.getInterfaces();
        for (Class c : interfaces) {
            System.out.println(c);
        }
        System.out.println();
        Package aPackage = clazz.getPackage();
        System.out.println(aPackage);
        System.out.println();
        Annotation[] annotations = clazz.getAnnotations();
        for (Annotation annotation : annotations) {
            System.out.println(annotation);
        }
    }
}
